<?PHP
session_start();
include("../config/connect.php");
include("../public/common.php");

if( !isset($_SESSION["gs_user"]) ) 
{
	$url = "Location:login.php";
	header($url);
}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>购物兔</title>
<style type="text/css">
<!--
body,td,th {
	font-family: 宋体;
	font-size: 13px;
	color: #000;
}
body {
	background-color: #FFF;
}
-->
</style>
<script language="javascript">

function ShowAll(  )
{
	window.location.href= "view_feedback.php?showtype=a";
	//window.location.reload();
}

function ShowDefault(  )
{
	window.location.href= "view_feedback.php";
	//window.location.reload();
}

function ShowPart(  )
{
	window.location.href= "view_feedback.php?showtype=p";
	//window.location.reload();
}

function Update( )
{

<?php
$input_item = CheckUrlParamNoDie( "input_item" );
$showtype = CheckUrlParamNoDie("showtype");
$tb_opt = CheckUrlParamNoDie("tb_opt");
if( $id != 0 && ($opt == "all" || $opt == "part" ) )
	echo "window.location.href=\"view_feedback.php?showtype=".$showtype."\";";
?>

	window.location.reload();
}

function OnFind()
{
	var input_item = document.getElementById("input_item").value;
	window.location.href= "view_feedback.php?showtype=<?PHP echo $showtype; ?>&input_item=" + input_item ;
}

//var timeoutID = setTimeout("Update( )", 60000);
</script>
</head>

<body>

<table width="100%" cellpadding="0" cellspacing="0" border="1" align="center">
	<tr>
    	<td height="25" width="50" align="center">序列号</td>
        <td align="center">时间</td>
   	  <td align="center">订单号</td>
      <td align="center">返现价格</td>
      <td  align="center">支付宝帐号</td>
	  <td width="71" align="center">对应</td>
	  <td width="61" align="center">操作</td>
      <td width="50" align="center">删除(只能删除多余的项)</td>
    </tr>
<?php
if( $tb_opt == "2" )
{
	$id = SetUrlParamInt( "id" );
	$sql = "update feedback set state=1 where id=$id limit 1";
	mysql_query( $sql );
	echo "<script>window.history.back()</script>";
	exit;
}
if( $tb_opt == "del" )
{
	$id = SetUrlParamInt( "id" );
	$sql = "delete from feedback where id=$id";
	mysql_query( $sql );
	echo "<script>alert(\"删除成功！\");window.history.back()</script>";
	exit;
}

if( $input_item != "" )
{
	$item = "%".$input_item."%";
	
	if( $showtype == "a" )
		$sql = "select * from feedback where item_id like '$item' order by id desc";	
	else
		$sql = "select * from feedback where item_id like '$item' and state=0 order by id desc ";	
	$result = mysql_query( $sql );
}
else
{
	if( $showtype == "a" )
		$sql = "select * from feedback order by id desc";	
	else
		$sql = "select * from feedback where state=0 order by id desc ";	
	$result = mysql_query( $sql );
}
while( $row = mysql_fetch_assoc( $result ))
{
?>
	<tr <?PHP if( $row["state"] == 1 ) echo "bgcolor=\"#33CCFF\"" ?> title="<?PHP echo $row["info"]; ?>">
		<td height="25" width="50" align="center"><?PHP echo $row["id"]; ?></td>
		<td align="center" title=""><?PHP echo $row["time"]; ?></td>
	  <td align="center" title="<?PHP echo $row["item_url"]; ?>" class="text_limit"><div class="text_limit"><?PHP echo $row["item_url"]; ?></div>&nbsp;</td>
	  <td align="center"><?PHP echo $row["price"]; ?>&nbsp;</td>
	  <td align="center"><?PHP echo $row["tb_id"]; ?>&nbsp;</td>
	  <td align="center"><?PHP if( $row["state"] == 1 )
												echo "<strong><span style=\"color:#F00\">是</span></strong>";
											else 
												echo "<a href=\"view_feedback.php?id=".$row["id"]."&tb_opt=2&showtype=".$showtype."&input_item=".$input_item."\">否</a>"; ?></td>
	  <td width="61" align="center"><a href="add_trade.php?id=<?php echo $row["id"]; ?>&opt_add=1">添加</a></td>
      <td width="50" align="center"><a href="view_feedback.php?id=<?php echo $row["id"]; ?>&tb_opt=del">删除</a></td>
	</tr>
<?PHP
}
?>
</table>
<table cellpadding="0" cellspacing="0" border="0" align="center">
	<tr>
    	<td width="800" height="30" align="center"><input type="text" value="" id="input_item" size="30"/><input type="button" onclick="javascript:OnFind();" value="查找" />&nbsp;&nbsp;&nbsp;<input type="button" value="显示所有" onclick="javascript:ShowAll()" />&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="默认" onclick="javascript:ShowDefault()" />&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="显示部分" onclick="javascript:ShowPart()" /></td>
    </tr>
</table>
</body>
</html>
